package company.tx1;

import java.util.Scanner;

public class Tx1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n1 = sc.nextInt();
        int[] array1 = new int[n1];
        for (int i = 0; i < n1; i++) {
            array1[i] = sc.nextInt();
        }
        int n2 = sc.nextInt();
        int[] array2 = new int[n2];
        for (int i = 0; i < n2; i++) {
            array2[i] = sc.nextInt();
        }
        int i = 0, j = 0;
        StringBuilder ans = new StringBuilder();
        while (i < n1 && j < n2) {
            if (array1[i] == array2[j]) {
                ans.append(array1[i]).append(" ");
                i++;
                j++;
            } else if (array1[i] > array2[j]) {
                i++;
            } else {
                j++;
            }
        }
        System.out.println(ans);
    }
}
